package controllers

import (
	"github.com/goravel/framework/contracts/http"
	httpfacade "github.com/hulutech-web/http_result"
	"goravel/app/models"
)

type SyslogController struct {
	//Dependent services
}

func NewSyslogController() *SyslogController {
	return &SyslogController{
		//Inject services
	}
}

// Index 系统日志
// @Summary      用户分页查询
// @Description  用户分页查询
// @Tags         SyslogController
// @Accept       json
// @Produce      json
// @Id SyslogIndex
// @Security ApiKeyAuth
// @Param Authorization header string false "Bearer 用户令牌"
// @Param  name  query  string  false  "name"
// @Param  pageSize  query  string  false  "pageSize"
// @Param  currentPage  query  string  false  "currentPage"
// @Param  sort  query  string  false  "sort"
// @Param  order  query  string  false  "order"
// @Success 200 {string} json {}
// @Router       /api/admin/syslog [get]
func (r *SyslogController) Index(ctx http.Context) http.Response {
	logs := []models.Syslog{}
	queries := ctx.Request().Queries()
	res, err := httpfacade.NewResult(ctx).SearchByParams(queries, nil).ResultPagination(&logs)
	if err != nil {
		return httpfacade.NewResult(ctx).Error(http.StatusInternalServerError, "", err.Error())
	}
	return res
}
